package com.tyc.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Value;

/**
 * 类描述
 *
 * @author tyc
 * @version 1.0
 * @date 2024-03-08 18:05:12
 */
@Aspect
@Slf4j
public class RedisAspect {
    //是否开启redis缓存  true开启   false关闭
    @Value("${spring.redis.open: false}")
    private boolean open;

    @Pointcut("execution(* com.tyc.utill.RedisUtil.*(..))")
    public void RedisPointCut(){

    }

    @Around("RedisPointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        Object result = null;
        if(open){
            try{
                result = point.proceed();
            }catch (Exception e){
                log.error("redis error", e);
//                throw new RRException("Redis服务异常");
            }
        }
        return result;
    }
}
